home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2169 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: maverick.tad.eds.com!stank01
  2. From: stank01@ny.rsc.gmeds.com (Shantanu G. Tank)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Returning a variable from system() function
  5. Date: 19 Jan 1996 16:55:12 GMT
  6. Organization: Eastern Resource Center
  7. Message-ID: <4doidg$nrj@maverick.tad.eds.com>
  8. References: <295336694wnr@iiga.demon.co.uk>
  9. NNTP-Posting-Host: gatekeeper.ny.rsc.gmeds.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. use popen instead...
  13.  
  14. Pete Ryan (pete@iiga.demon.co.uk) wrote:
  15. : Hiya,
  16. :     I`ve just been experimenting with C on UNIX and have come across a 
  17. : problem!.  There is a UNIX command called `find / -name gwire -print` 
  18. : which scans the UNIX drive for files/directories containing `gwire`.  
  19. : Anyway what I want to do is the following...
  20.  
  21. : #include <stdio.h>
  22. : #include <stdlib.h>
  23. : etc
  24.  
  25. : void main()
  26. : {
  27. :     char    tmp[];
  28. :     
  29. :     chdir("/usr2/willesden");    
  30. :     
  31. :     */ offending code below ;( */
  32. :     tmp = system("find . -name gwire");
  33.  
  34. :     printf("%s",tmp");
  35.  
  36. : }
  37.  
  38. : Therefore if I run `find . -name gwire -print` it returns all the 
  39. : directories containing `gwire`.  However the code above does not 
  40. : work!!. Is it because `= system` returns an integer and not strings???
  41.  
  42. : Any help would be very much appreciated as I have only just started 
  43. : learning c in the last 2 months.  
  44.  
  45. :  
  46. : -------------------------------| 
  47. : | EMail pete@                  |
  48. : | Mail sent via Demon Internet |
  49. : --------------------------------
  50.  
  51. --
  52. Shantanu G. Tank
  53. EDS ERC                    Phone:716-439-3858 (8-449)
  54. Internet:    stank01@ny.rsc.gmeds.com
  55. Lotus Notes: Shantanu G. Tank@UG_GM_LOC_HDL01   DIAMONDNET:  LNUSHDLK(RZJNJJ)
  56.